<%--
 *  File:   OrganizationBaseData.jsp
 *  Desc:	Report Director depend on eSpreadsheet
 *
 *  Date		         Author		      Changes
 *  2009-12-15	  		visazhou	 	  Created
 *   
 *
 *  Copyright (C) 2000 - 2008 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%//init param
			String privilegeCode = "10227";
			//String strTableName = "";
			String strModuleName = "COM";
			String contextPath = request.getContextPath();

			%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>
<%@ include file="/inc/NewCalendar.inc" %>

<iframe name="reloadHandler" style="display:none"></iframe>
<html>
<head>
<title>OrganizationBaseData</title>
<PageFlow:CheckPageFlow pageName="p_zmydeptname" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%Vector totalsummary = (Vector) pageContext.getAttribute("totalsummary");
			if (totalsummary == null)
				totalsummary = new Vector();

			HashMap UserInfo = (HashMap) session.getAttribute("userinfo");
			if (UserInfo == null)
				UserInfo = new HashMap();
    Integer loginemployeeid = (Integer)UserInfo.get("employeeid");
    Integer nCurUserId = (Integer)UserInfo.get("userid");
    
    java.util.Calendar cal = java.util.Calendar.getInstance(); 

    
    HashMap orgInfo = (HashMap)pageContext.getAttribute("orginfo");

    if(orgInfo == null)
      orgInfo = new HashMap();
    
    Integer ishead = (Integer)orgInfo.get("ischain");
    if(ishead==null)
  	  ishead = new Integer(-1);
			%>

<%--  put your custom script here   --%>
</head>
<body style="overflow: auto;" >
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
	<input type="hidden" name="pagenameX" value="p_zmydeptname">
	<input type="hidden" name="actionname">
	<input type="hidden" name="prodcode">
    <input type="hidden" name="flag"/>
	<custom:hidden property="languagecode" scope="session" name="userinfo"/>
	<custom:hidden property="contactid" scope="session" name="userinfo" changedName="loginid"/>
	<%--  page location   --%>
<%@ include file="/inc/PageLocation.inc"%>
 
<script language="JavaScript">

function page_popBusinessarea()
{
  if (typeof popwindow != 'undefined') popwindow.close();
  popwindow = window.open("<%=contextPath%>/masterdata/ogm/zylstdbusinessareapop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}
function SetSalesMan(username,employeename){
	document.cform.employeecode.value=username;
	document.cform.employeename.value=employeename;
}
function setContact(value,areatype,areaname){
	document.cform.strareaid.value=value;
	document.cform.strareaname.value=areaname;
	//document.cform.stdareatype.value=areatype;
}
function page_popwindow(blue)
{
  if (typeof popwindow != 'undefined') popwindow.close();
  popwindow = window.open("<%=contextPath%>/zyl/masterdata/analysislist/EmployeeBussise.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}

function downloadcsv() {
	var deptid= document.cform.deptname.value;//部门id
	var area2name= document.cform.strareaname.value;//省区名称
	var strareaid= document.cform.strareaid.value;//省区ID
	var username= document.cform.employeecode.value;//代表code
	var pharmacyLevelValue = document.cform.grade.value;//商业级别
   	var productgroupid=document.cform.productgroupname.value;//产品组
    var orgpropertyvalue=document.cform.gardeA.value;//药店类型
	var statusvalue = document.cform.status.value;//状态
    var startyears=document.cform.startyears.value;//年份
    var startmonths=document.cform.startmonths.value;//月份

	if(startyears=="" && startmonths==""){
		//var url1 = "<%= reportURL %>/servlet/ExcecuteReport/OrganizationBaseData114C.sox?__format=xlsx&__folder=/ovalreport&globalpccode=114&deptid="+deptid+"&strareaid="+strareaid+"&username=" +username+"&pharmacyLevelValue="+pharmacyLevelValue+"&productgroupid="+productgroupid+"&orgpropertyvalue="+orgpropertyvalue+"&statusvalue="+statusvalue;
		var url1 = "<%=newreportURL %>/xlsrpt?reportname=OrganizationBaseData114C&globalpccode=114&deptid="+deptid+"&strareaid="+strareaid+"&username=" +username+"&pharmacyLevelValue="+escape(encodeURI(pharmacyLevelValue))+"&productgroupid="+productgroupid+"&orgpropertyvalue="+orgpropertyvalue+"&statusvalue="+statusvalue+"&timestamp="+Date.parse(new Date())+"&<%= OvalTools.randomURL() %>";
	}
	
	else if(startyears=="" && startmonths!==""){
		alert("<%= message.getMessageDesc("YEARDATE_NOT_NULL")%>");
	}
	
	else if(startyears!=="" && startmonths==""){
		alert("<%= message.getMessageDesc("MONTHSDATE_NOT_NULL")%>");
	}
	
	else{
		var begindate = document.cform.startyears.value+"-"+document.cform.startmonths.value;//开始日期
		//var url1 = "<%= reportURL %>/servlet/ExcecuteReport/OrganizationBaseData114.sox?__format=xlsx&__folder=/ovalreport&globalpccode=114&deptid="+deptid+"&strareaid="+strareaid+"&username=" +username+"&pharmacyLevelValue="+pharmacyLevelValue+"&productgroupid="+productgroupid+"&orgpropertyvalue="+orgpropertyvalue+"&statusvalue="+statusvalue+"&begindate="+begindate;
		var url1 = "<%=newreportURL %>/xlsrpt?reportname=OrganizationBaseData114&globalpccode=114&deptid="+deptid+"&strareaid="+strareaid+"&username=" +username+"&pharmacyLevelValue="+escape(encodeURI(pharmacyLevelValue))+"&productgroupid="+productgroupid+"&orgpropertyvalue="+orgpropertyvalue+"&statusvalue="+statusvalue+"&begindate="+begindate+"&timestamp="+Date.parse(new Date())+"&<%= OvalTools.randomURL() %>";
	}
	DataReport(url1);
	//var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
	//popwindow = window.open(url1, "n1window", strstatus);
}
function downloadcsvA() {
	var deptid= document.cform.deptname.value;//部门id
	var area2name= document.cform.strareaname.value;//省区名称
	var strareaid= document.cform.strareaid.value;//省区ID
	var username= document.cform.employeecode.value;//代表code
	var pharmacyLevelValue = document.cform.grade.value;//商业级别
   	var productgroupid=document.cform.productgroupname.value;//产品组
    var orgpropertyvalue=document.cform.gardeA.value;//药店类型
	var statusvalue = document.cform.status.value;//状态
	var startyears=document.cform.startyears.value;//年份
    var startmonths=document.cform.startmonths.value;//月份

	if(startyears=="" && startmonths==""){
		//var url1 = "<%= reportURL %>/servlet/ExcecuteReport/OrganizationBaseData114D.sox?__format=xlsx&__folder=/ovalreport&globalpccode=114&deptid="+deptid+"&strareaid="+strareaid+"&username=" +username+"&pharmacyLevelValue="+pharmacyLevelValue+"&productgroupid="+productgroupid+"&orgpropertyvalue="+orgpropertyvalue+"&statusvalue="+statusvalue+"&employeeid="+<%=nCurUserId%>;
		var url1 = "<%=newreportURL %>/xlsrpt?reportname=OrganizationBaseData114D&globalpccode=114&deptid="+deptid+"&strareaid="+strareaid+"&username=" +username+"&pharmacyLevelValue="+escape(encodeURI(pharmacyLevelValue))+"&productgroupid="+productgroupid+"&orgpropertyvalue="+orgpropertyvalue+"&statusvalue="+statusvalue+"&employeeid="+<%=nCurUserId%>+"&timestamp="+Date.parse(new Date())+"&<%= OvalTools.randomURL() %>";
	}
	
	else if(startyears=="" && startmonths!==""){
		alert("<%= message.getMessageDesc("YEARDATE_NOT_NULL")%>");
	}
	
	else if(startyears!=="" && startmonths==""){
		alert("<%= message.getMessageDesc("MONTHSDATE_NOT_NULL")%>");
	}
	
	else{
		var begindate = document.cform.startyears.value+"-"+document.cform.startmonths.value;//开始日期
		//var url1 = "<%= reportURL %>/servlet/ExcecuteReport/OrganizationBaseData114B.sox?__format=xlsx&__folder=/ovalreport&globalpccode=114&deptid="+deptid+"&strareaid="+strareaid+"&username=" +username+"&pharmacyLevelValue="+pharmacyLevelValue+"&productgroupid="+productgroupid+"&orgpropertyvalue="+orgpropertyvalue+"&statusvalue="+statusvalue+"&begindate="+begindate+"&employeeid="+<%=nCurUserId%>;
		var url1 = "<%=newreportURL %>/xlsrpt?reportname=OrganizationBaseData114B&globalpccode=114&deptid="+deptid+"&strareaid="+strareaid+"&username=" +username+"&pharmacyLevelValue="+escape(encodeURI(pharmacyLevelValue))+"&productgroupid="+productgroupid+"&orgpropertyvalue="+orgpropertyvalue+"&statusvalue="+statusvalue+"&begindate="+begindate+"&employeeid="+<%=nCurUserId%>+"&timestamp="+Date.parse(new Date())+"&<%= OvalTools.randomURL() %>";
	}
	DataReport(url1);
	//var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
	//popwindow = window.open(url1, "n1window", strstatus);
}
</script>
<table width="100%" border="0" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
<!-------------------------------------1 row -------------------------------------------------->
	<tr>
		<td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_Department")+ label.getLabelName("L_Colon")%>
			</div>
		</td>
		<td style="width:90px;" class="td_left">
							<custom:select optionInnerTextKey="deptname" optionsName="alldeptnames" optionValueKey="deptid" property="deptname" name="alldeptnames"  defaultValue="--------" defaultValueCost=""/>
	   </td>
        <td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_Provicetdr")+label.getLabelName("L_Colon")%>
			</div>
		</td>
		<td><!--<custom:text property="businessareaname"/>-->
					<custom:hidden property="stdareatype" />
		           	<custom:text property="strareaname"/>
		           	<custom:hidden property="strareaid" />
		           	<a onclick="page_popBusinessarea();"><custom:button type="3" value="*"/></a>
				</td>

		<td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_Representative")+ label.getLabelName("L_Colon")%>
			</div>
		</td>
           <td width="228" >
					<custom:hidden property="employeeid" />
		           	<custom:hidden property="employeecode"/>
		           	<custom:text property="employeename"/>
              <a onclick="page_popwindow();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
          </td>

			<td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_DrugstoreLevel")	+ label.getLabelName("L_Colon")%>
			</div>
		</td>
	            <td style="width:90px;" class="td_left">
	                      <custom:selectdic dictType="PharmacyLevel" property="grade" valueCriteria="1,2,3" defaultValue="------" defaultValueCost="" command="notnull" label="L_Property"/>
	   </td>
	</tr>
<!-------------------------------------2 row -------------------------------------------------->
	<tr>
	<%
                  String year = cal.get(Calendar.YEAR)+"";     
				  String month = cal.get(Calendar.MONTH)+"";
				if(cal.get(Calendar.MONTH) == 0){
month = "12";
year = (cal.get(Calendar.YEAR)-1)+"";
}  

%>
		<td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_Start")+label.getLabelName("L_Year")+label.getLabelName("L_Colon")%>
			</div>
		</td>
	    <td >
	    <!-- 
          <custom:selectdic property="startyears" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1" />
	     -->
          <custom:selectdic property="startyears" dictType="Years"  defaultValue="--------" defaultValueCost="" label="L_Year1" />
        </td>
		<td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_Start")+label.getLabelName("L_Month")+label.getLabelName("L_Colon")%>
			</div>
		</td>
		<td class="title_center">
			<div align="left">
			<!-- 
				<custom:selectdic property="startmonths" dictType="Months" command="notnull" value="<%=month %>" label="L_Month" />
			 -->
				<custom:selectdic property="startmonths" dictType="Months"  defaultValue="--------" defaultValueCost="" label="L_Month" />
			</div>
		</td>
          <td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_ProductGroupName")	+ label.getLabelName("L_Colon")%>
			</div>
		</td>
    <td style="width:90px;" class="td_left">
			<custom:select optionInnerTextKey="productgroupname" optionsName="allgroupnames" optionValueKey="productgroupid" property="productgroupname" name="allgroupnames"  defaultValue="--------" defaultValueCost=""/>
					
	   </td>
	             <td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_Status")	+ label.getLabelName("L_Colon")%>
			</div>
		</td>
    	<td style="width:90px;" class="td_left">
					<custom:selectdic dictType="Status" property="status" valueCriteria="28,41" defaultValue="------" defaultValueCost=""/>
	   </td>
	</tr>
	<tr>
	 <td class="title_center">
			<div align="right">
			 <%=label.getLabelName("L_PharmacyType")	+ label.getLabelName("L_Colon")%>
			</div>
		</td>
	<td style="width:90px;" class="td_left">
		<custom:selectdic dictType="PharmacyType" property="gardeA" valueCriteria="11,12" defaultValue="------" defaultValueCost=""/>
	   </td>
	</tr>
<!--	-----------------------------------------4row---------------------------------------->

 </table>

		 <table width="100%" cellspacing="0" cellpadding="0">
		        <tr>
		          <td class="summary_top"></td>
		        </tr>
		        <tr>
		          <td class="summary_top"></td>
		        </tr>
		        <tr>
		          <td class="summary_top"></td>
		        </tr>
		        <tr>
		          	<td class="td_center">
				  		<a onclick="javascript:downloadcsv();">
				  		<custom:button type="1" label="L_CenterPeople" imgsrc="CreatSubDept.gif" border="0" privilegeCode="BB1022702"/></a>
				  		<a onclick="javascript:downloadcsvA();">
				  		<custom:button type="1" label="L_AreaPeople" imgsrc="CreatSubDept.gif" border="0" privilegeCode="BB1022701"/></a>
					</td>
		        </tr>
     	</table>
	</table>
</form>
</body>
</html>
